<script setup lang="ts">
withDefaults(
  defineProps<{
    money: number;
    car?: string;
  }>(),
  {
    car: 'Tesla',
  }
);

// emit 是定义完事件后的触发器
const emit = defineEmits<{
  (eventName: 'changeMoney', money: number): void;
  (eventName: 'changeCar', car: string): void;
}>();

const onChangeMoneyOfHome = (money: number) => {
  console.log('[ onChangeMoney ] 执行了', money);
};

defineExpose({
  onChangeMoneyOfHome,
  emitOfHome: emit,
});
</script>

<template>
  <div>
    money: {{ money }}
    <button @click="emit('changeMoney', 200)">changeMoney</button>
  </div>
  <div>car: {{ car }}</div>
</template>
